<template>
  <div class="hyydxq">
    <!-- 标准化生产 -->
    <div class="page_title">
      <span>标准化加工</span>
    </div>

    <div class="box">
      <!--      <div class='top-box'>-->
      <!--        <div class='col-fff font-18 top-title'>标准化加工</div>-->
      <!--      </div>-->
      <div class="flex-between small-box">
        <div style="width: 50%; margin-left: 10px" @click="goTraceability()">
          <img class="img" src="../../assets/img/standardized/traceability_icon.png" />
        </div>
        <div style="width: 50%; margin-right: 10px" @click="goConnect()">
          <img class="img" src="../../assets/img/standardized/connect_icon.png" />
        </div>
      </div>
    </div>
    <div class="box-title" @click="goConnect()">
      <title-panel :moreShow="true" title="生鲜乳交接" />
    </div>
    <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
      <template v-if="list && list.length > 0">
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
          <van-cell v-for="(item, index) in list" :key="index" class="approvalItem content" @click="detail(item)">
            <div class="flex-between font-14 line-height-3">
              <div class="col-333333 font-bold-500 font-15 m-r-10">{{ item.deliveryBatchNo }}</div>
            </div>
            <div class="flex-between font-13 line-height-3">
              <div class="col-666666 m-r-10">交接日期：{{ item.deliveryDate }}</div>
            </div>
            <div class="flex-between font-13 line-height-3">
              <div class="col-666666 m-r-10">生鲜乳总数量（kg）：{{ item.freshMilkTotal }}</div>
            </div>
            <div class="flex-between font-14 line-height-3">
              <div class="col-666666 line-text-out text-right">创建人：{{ item.createdByName }}</div>
              <div class="col-666666 m-r-10 line-text-out">创建时间：{{ item.createTime }}</div>
            </div>
          </van-cell>
        </van-list>
      </template>
      <template v-else>
        <!-- <van-empty :image="require('@/assets/img/noData.png')" description="暂无数据" /> -->
        <temporarilyData style="position: relative; top: -80px;"></temporarilyData>
      </template>
    </van-pull-refresh>
  </div>
</template>

<script>
/**
 * 标准化生产
 **/
import { getValue, setValue } from '@/utils/auth'
import TitlePanel from '@/components/titlePanel'
import temporarilyData from '@/components/temporarilyData.vue';
import {
  Toast,
  Cell,
  CellGroup,
  Popup,
  Picker,
  DatetimePicker,
  PullRefresh,
  CheckboxGroup,
  List,
  Image,
  Empty
} from 'vant'
import { getHandle } from '@/api'
export default {
  components: {
    temporarilyData,
    TitlePanel,
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
    [Popup.name]: Popup,
    [Picker.name]: Picker,
    [DatetimePicker.name]: DatetimePicker,
    [PullRefresh.name]: PullRefresh,
    [CheckboxGroup.name]: CheckboxGroup,
    [Toast.name]: Toast,
    [List.name]: List,
    [Empty.name]: Empty,
    [Image.name]: Image
  },
  data() {
    return {
      // traceability: require('../../assets/img/standardized/traceability_icon.png'),
      // connect: require('../../assets/img/standardized/connect_icon.png'),
      refreshing: false,
      currentDate: new Date(),
      list: [],
      loading: false,
      finished: false,
      params: {
        page: 1,
        limit: 10,
        tenantCode: getValue('tenantCode'),
        subjectInfoId: getValue('subjectInfoId')
      }
    }
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    goTraceability() {
      this.$bridge.call('salesTraceabilityCodeQuery')
    },
    goConnect() {
      this.$bridge.call('rawMilkConnect')
    },
    detail(item) {
      setValue('connectId', item.id)
      this.$bridge.call('rawMilkConnectDetail')
    },
    // 卡片列表
    onRefresh() {
      this.params.page = 1
      this.finished = false

      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true
      this.onLoad()
    },
    onSearch() {
      this.params.page = 1
      this.list = []
      this.finished = false

      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true
      this.onLoad()
    },
    onLoad() {
      getHandle('/agri/api/yzbzh/freshMilkDelivery/queryListPage', this.params).then(res => {
        if (this.refreshing) {
          this.list = []
          this.refreshing = false
        }
        this.list = this.list.concat(res.data.rows)
        this.loading = false

        if (this.list.length >= res.data.count) {
          this.finished = true
        } else {
          this.params.page = this.params.page + 1
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.topCeiling {
  position: fixed;
  top: 0;
  z-index: 1;
}
.page_title {
  width: 100%;
  height: 44px;
  background-color: #37b5b5;

  line-height: 44px;

  box-sizing: border-box;
  text-align: center;
  align-items: center;
  justify-content: space-between;
  span {
    font-size: 18px;
    color: #fff;


  }

}
.topDate {
  width: 80%;
  margin: auto;
  display: flex;
  justify-content: space-between;
  > p {
    font-size: 15px;
    &:first-child {
      width: 40%;
    }
    &:last-child {
      width: 40%;
    }
  }
}
.van-field__control {
  border: 0 !important;
}
.content {
  //   border-bottom: 1px solid #eee;
  padding: 10px 15px;
}
.img {
  width: 100%;
}
.box {
  //position: relative;
}
.top-box {
  height: 110px;
  background: #37b5b5;
}
.top-title {
  width: 100%;
  line-height: 44px;
  text-align: center;
}
.small-box {
  //position: absolute;
  //top: 60%;
  width: 100%;
  margin-top: 20px;
}
.box-title {
  margin-top: 10px;
  height: 50px;
}
::v-deep .van-cell {
  border-bottom: none
}
[data-v-2f2c427a] .van-cell {
  border-bottom: none;
}
</style>
